package org.come.MountShouHu;

import com.tool.image.ImageMixDeal;
import com.tool.tcpimg.UIUtils;
import org.come.Frame.MountShouhuJframe;
import org.come.Jpanel.MountShouhuJpanel;

import javax.swing.*;
import java.awt.*;

public class shuxingRenderer extends JPanel implements ListCellRenderer {
public static String vs;
private int index;

public shuxingRenderer(final int index) {
	this.index = index;
}

public shuxingRenderer() {
	this.index = 67;
}

@Override
public Dimension getPreferredSize() {
	return new Dimension(this.getWidth() / 2, 25);
}

@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
	final shuxingRenderer mr = new shuxingRenderer(index);
	this.index = index;
	mr.removeAll();
	if (MountShouhuJpanel.shuxingidx == index || isSelected) {
		mr.setBackground(new Color(0, 0, 0, 0));
	} else {
		mr.setOpaque(false);
	}
	mr.setLayout(new FlowLayout(0));
	final Box box = Box.createHorizontalBox();
	box.add(new JLabel() {
		{
			this.setForeground(Color.BLACK);
			this.setText("");
			try {
				if (ImageMixDeal.userimg.getRoleShow().getFighting() != 0) {
					{
						{
                              /*  final Iterator<Mount> iterator = UserMessUntil.getMountlsit().listIterator();
                                while (iterator.hasNext()) {
                                    final Mount roleSummoning = iterator.next();
                                  //  final Iterator<TypeState> iterator2 = data.iterator();
                                 *//*   while (iterator2.hasNext())*//* {
                                      //  final TypeState datum = (TypeState)iterator2.next();
                                      *//*  if (datum.getType().equals(roleSummoning.getSid().toString()))*//* {
                                            this.put(roleSummoning.getMountname(), roleSummoning.getMid().intValue());
                                        }
                                    }
                                }*/
                              /*  if (mountShouhuJpanel.getZonglanmode().isEmpty()){
                                   for (int i=0;i<=mountShouhuJpanel.getZonglanmode().size()-1;i++){
                                       map.add(mountShouhuJpanel.getZonglanmode().get(i));
                                   }
                                }*/
							if (isSelected) {
								mr.setBackground(Color.GRAY);
							} else mr.setBackground(Color.black);
							
						}
					}
                
                }
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}
	});
	mr.add(box);
	return mr;
}

@Override
protected void paintComponent(Graphics g) {
	super.paintComponent(g);
	final Graphics2D g2d = (Graphics2D) g;
	g2d.setColor(Color.green);
	g2d.setFont(UIUtils.TEXT_NAME_FONT15);
	//  for (int i=0;i<=MountShouhuJpanel.shuxing.size()-1;i++){
	if (MountShouhuJpanel.shuxing.size() > 0) {
		String[] m = MountShouhuJpanel.shuxing.get(index).split("级");
		int xuan= MountShouhuJframe.getMountShouhuJframe().getMountShouhuJpanel().getXuanzhong();
		int k=0;
		switch (xuan){
			case 0:
				k=MountShouhuJframe.getMountShouhuJframe().getMountShouhuJpanel().shouHu.zhongtianlvl;
				break;
			case 1:
				k=MountShouhuJframe.getMountShouhuJframe().getMountShouhuJpanel().shouHu.qinglonglvl;
				break;
			case 2:
				k=MountShouhuJframe.getMountShouhuJframe().getMountShouhuJpanel().shouHu.baihulvl;
				break;
			case 3:
				k=MountShouhuJframe.getMountShouhuJframe().getMountShouhuJpanel().shouHu.xuanwulvl;
				break;
			case 4:
				k=MountShouhuJframe.getMountShouhuJframe().getMountShouhuJpanel().shouHu.zhuquelvl;
				break;
			
		}
		if (Integer.parseInt(m[0]) <= k)
			g2d.setColor(new Color(0Xb1b051));
		else g2d.setColor(Color.GRAY);
		g2d.drawString(MountShouhuJpanel.shuxing.get(index), 5, 15);
	}
	
	//   }
}
}
